package org.linlinjava.litemall.db.service;

import org.linlinjava.litemall.db.dao.NewsPayMapper;
import org.linlinjava.litemall.db.domain.NewsPay;
import org.linlinjava.litemall.db.domain.NewsPayExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @description:
 * @program: mall
 * @author: youvy
 * @create: 2019-12-04 11:04
 **/
@Service
public class NewsPayService {
	@Resource
	private NewsPayMapper newsPayMapper;
	public int insert(NewsPay newsPay){
		int i = newsPayMapper.insertSelective(newsPay);
		return i;
	}
	public int countByNewsIdAndUserId(int newsId,int userId){
		NewsPayExample example = new NewsPayExample();
		example.or().andNewsIdEqualTo(newsId).andUserIdEqualTo(userId);
		long l = newsPayMapper.countByExample(example);
		return (int)l;
	}

	public NewsPay findByNewsId(int newsId,int userId){
		NewsPayExample example = new NewsPayExample();
		example.or().andNewsIdEqualTo(newsId).andUserIdEqualTo(userId);
		NewsPay newsPay = newsPayMapper.selectOneByExample(example);
		return newsPay;
	}

	public int update(NewsPay newsPay){
		int i = newsPayMapper.updateByPrimaryKeySelective(newsPay);
		return i;
	}

	public NewsPay findById(int id){
		NewsPay newsPay = newsPayMapper.selectByPrimaryKey(id);
		return newsPay;
	}


}
